import React, { useContext } from 'react';
import { Tooltip, Col, Card, Button, message } from 'antd';

import { ExpertsUpdateContext } from '../common/ExpertsContext';

import { EditOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons';
import pageStyles from '@/common/pageLayout.less';
import { btntTxtStyle, onMouseOutBtn } from '@/utils';

const UpdateExpertsCardDocumentInfo: React.FC<ExpertsUpdateAPI.IUpdateExpertsCardDocumentInfo> = ({ children, onExtra }) => {
  const { prefixCls, isView, expertQualifies, expertsInfo } = useContext(ExpertsUpdateContext);

  const operate = () => {
    return (
      <div style={{ display: 'flex' }}>
        <Tooltip title={'添加证书信息'}>
          <Button
            size="small"
            // icon={<PlusOutlined />}
            type={'link'}
            className="manageBtntTxtStyle"
            onMouseUp={onMouseOutBtn}
            onClick={() => {
              if (!expertsInfo?.id) {
                message.warning('请先添加专家信息');
              } else {
                onExtra(true, 'add');
              }
            }}
          >
            添加
          </Button>
        </Tooltip>
        <Tooltip title={'编辑证书信息'}>
          <Button
            size="small"
            // icon={<EditOutlined />}
            type={'link'}
            className="manageBtntTxtStyle"
            onMouseUp={onMouseOutBtn}
            onClick={() => {
              if (expertQualifies?.length == 0 || !expertsInfo?.id) {
                message.warning('请先添加专家信息和证书信息');
              } else {
                onExtra(true, 'edit');
              }
            }}
          >
            编辑
          </Button>
        </Tooltip>
      </div>
    );
  };

  return (
    <Col span={8} className={`${prefixCls}row-col`}>
      <Card title={'证书信息'} className={pageStyles['page-view-cardView']} bodyStyle={{ padding: '0px' }} extra={!isView && operate()}>
        <div className={`${prefixCls}container`}>{children}</div>
      </Card>
    </Col>
  );
};

export default UpdateExpertsCardDocumentInfo;
